<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author: Author: HCZ <huangchengze@etrol.com> 
// +----------------------------------------------------------------------

namespace app\warning\controller;

use app\common\controller\Admin;
use app\warning\controller\api\History as HistoryApi;

/**
 * 预警预测历史
 * @package app\Event
 */
class History  extends Admin{
	protected $api;
	
	public function _initialize()
	{
		parent::_initialize();
		$this->api = new HistoryApi();
	}
	
	/**
	 * 历史呈现
	 */
	public function index(){
		if(IS_AJAX){
			$historyList = $this->api->getHistoryList();
			return $historyList;
		}
		//单位列表
		$enterpriseList = model('basic/Enterprise')->getSelectList($this->scope);
		$this->assign('enterpriseList',$enterpriseList);
		//危险等级
		$riskDegree = model('Config')->where('groupName','risk_degree')->column('title','name');
		$this->assign('riskDegree',$riskDegree);
		return $this->fetch();
	}
	
	/**
	 * 历史预警查询
	 * @return Json
	 */
	public function search() {
		if(IS_AJAX){
			$itemList = $this->api->search(input('riskDegree'),input('enterpriseId'),input('start'),input('end'));
			return $itemList;
		}
	}
	
}